/*
 *  Dino.c
 *  final
 *
 *  Created by Javier Quevedo on 1/21/09.
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
 *
 */
#import "Dino.h"
#import "Model.h"
#import "Node.h"
//#include "Model.h"
//#include "Node.h"


Dino *initDino(){
	Dino *newDino = malloc(sizeof(Dino));
	
	newDino->files = malloc(sizeof(char)*4*40);
	newDino->files[0] = "models/dino/arm.sgf";
	newDino-> files[1] ="models/dino/body.sgf",
	newDino-> files[2] ="models/dino/eyes.sgf",
	newDino-> files[3] ="models/dino/leg.sgf";
	
	
	newDino->model = malloc(sizeof(Model));
	LoadModel(newDino->model, newDino->files , 4);
	
	newDino->state = DS_Stop;

	newDino->main= initNode();
	newDino->main->modelPart = NULL;
	setNodeRotation(newDino->main, 90.0, 0.0, 1.0, 0.0);
	setNodeTranslation(newDino->main, -0.15, 0.01, 1.0);
	
	
	newDino->body = initNode();
	newDino->body->modelPart = newDino->model->modelParts[1];
	addChild(newDino->main, newDino->body);
	
	
	//setNodeScale(newDino->main, 0.2, 0.2, 0.2);
	
	newDino->eyes = initNode();
	newDino->eyes->modelPart = newDino->model->modelParts[2];
	setNodeTranslation(newDino->eyes, 0.0, 0.0, -0.1);
	addChild(newDino->body, newDino->eyes);
	
	newDino->leftArm = initNode();
	newDino->leftArm->modelPart = newDino->model->modelParts[0];
	//newDino->leftArm->modelPart->texture=initTexture("textures/rock.rgb");
	setNodeTranslation(newDino->leftArm, 0.0, 0.0, -0.5);
	
	addChild(newDino->body, newDino->leftArm);

	newDino->rightArm = initNode();
	newDino->rightArm->modelPart = newDino->model->modelParts[0];
	addChild(newDino->body, newDino->rightArm);
	setNodeTranslation(newDino->rightArm, 0.0, 0.0, 2.5);
	
	newDino->leftLeg = initNode();
	newDino->leftLeg->modelPart = newDino->model->modelParts[3];
	setNodeTranslation(newDino->leftLeg, 0.0, 0.0, -0.5);
	//newDino->leftLeg->modelPart->texture=initTexture("textures/ground.rgb");
	addChild(newDino->body, newDino->leftLeg);
	
	newDino->rightLeg = initNode();
	newDino->rightLeg->modelPart = newDino->model->modelParts[3];
	setNodeTranslation(newDino->rightLeg, 0.0, 0.0, 2.5);
	addChild(newDino->body, newDino->rightLeg);
	
	return newDino;
}

void setDinoSize(Dino *dino, GLfloat dinoSize)
{
	dino->size[0]=dinoSize;
	dino->size[1]=dinoSize;
	dino->size[2]=dinoSize;
	setNodeScale(dino->main, dinoSize, dinoSize, dinoSize);



}

void releaseDino(Dino *dino){

}

